package top.lingkang.finalgateway.core.ssl;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import lombok.extern.slf4j.Slf4j;
import top.lingkang.finalgateway.config.RouterConfig;

import javax.net.ssl.SSLContext;

/**
 * @author lingkang
 * Created by 2024/5/5
 */
@Slf4j
public class SslJksServerInitHandler extends ChannelInitializer<SocketChannel> {
    public final RouterConfig config;
    public final SslConfig sslConfig;
    public final SSLContext sslContext;

    public SslJksServerInitHandler(RouterConfig config, SslConfig sslConfig, SSLContext sslContext) {
        this.config = config;
        this.sslConfig = sslConfig;
        this.sslContext = sslContext;
    }

    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        ch.pipeline().addLast(new RedirectToJksHttpsHandler(this));
    }
}
